import React, { Component } from 'react'
import './mySet.less'
import '../my/myMessage.less'
import Head from '../../../components/head/hrader'
import cookies from 'js-cookie'

import { connect } from 'react-redux';
import fun from '../../../store/action/index'
class MySet extends Component {
    constructor() {
        super()
        this.state = {
            headtitle: { title: '我的设置', path: '/my' },
            myMessagedata: [//信息
                { title: '头像', age: '' },
                { title: '昵称', age: '' },
                { title: '性别', age: '' },
            ],
            myMessagesite: [//地址
                { title: '修改密码', age: '', id: 0 },
                { title: '收货地址', age: '', id: 1 },
            ],
        }
    }
    render() {
        let { headtitle, myMessagedata, myMessagesite, nowindex } = this.state
        return (
            <div className="myMessage_box">
                <div className="myMessage_header">
                    <Head title={headtitle} />
                </div>
                {/* 个人信息 */}
                {/* <div className="myMessage_body">
                    {myMessagedata.map((item, index) => {
                        return <div className="myMessage_content" key={index}>
                            <div onClick={() => { this.aaa() }}>{item.title}</div>
                            <div>
                                <p className={index === 0 ? 'myMessage_img' : null}>img</p>
                                <p className="iconfont icon-fanhui1"></p>
                            </div>
                        </div>
                    })}
                </div> */}
                {/* 地址 */}
                <div className="myMessage_body">
                    {myMessagesite.map((item, index) => {
                        return <div className="myMessage_content" key={index}
                            onClick={() => { this.aaa(index) }}>
                            <div>{item.title}</div>
                            <div>
                                <p></p>
                                <p className="iconfont icon-fanhui1"></p>
                            </div>
                        </div>
                    })}
                </div>
                <div className="mySet_quit" onClick={() => { this.quit() }}>退出登录</div>
            </div>
        )
    }
    aaa = (index) => {
        console.log(index);
        if (index === 0) {
            this.props.history.push({
                pathname: '/mySetson',
                state: this.state.myMessagesite[index],
                index,
            })
        } else if (index === 1) {
            this.props.history.push({
                pathname: '/mySite',
                state: this.state.myMessagesite[index],
            })
        }

    }
    // 退出登录
    quit = () => {
        //
        cookies.remove('usertoken')
        cookies.remove('user_id')
        // let path = this.props.location.pathname
        this.props.setNav(null)
        this.props.history.push({
            pathname: '/login',
            state: '/home',
        })
    }
}
export default connect(state => state.Login, fun.loginAction)(MySet)